<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>
	function insertFn()
	{
		var frm=document.frm01;
	/* 	var idNum1=frm.idNum1.value;
		var idNum1Month=parseInt(idNum1.substr(2,2));
		var idNum1Day=parseInt(idNum1.substr(4,2));
	 	var idNum2=frm.idNum2.value;
		var idNum2Gender=parseInt(idNum2.substr(0,1));
		var lastDayIdNum1=0; 
		var idNumYear=0;
		
	  	if(idNum2Gender<3){
			idNumYear=parseInt("19"+idNum1.substr(0,2)); 
			lastDayIdNum1 = (new Date(idNumYear, idNum1Month, 0)).getDate();
		} else if(idNum2Gender>2||idNum2Gender<5){
			idNumYear=parseInt("20"+idNum1.substr(0,2)); 
			lastDayIdNum1 = (new Date(idNumYear, idNum1Month, 0)).getDate();
		}  
		var gYear=frm.year1.value;
		if(gYear!=""){
			gYear=parseInt(frm.year1.value);
		}
		var gMonth=frm.month1.value;
		if(gMonth!=""){
			gMonth=parseInt(frm.month1.value);
		}
		var gDay=frm.day1.value;
		if(gDay!=""){
			gDay=parseInt(frm.day1.value);
		}
		var lastDayGdate=0;
		if(gYear!="" && gMonth!=""){
			lastDayGdate=(new Date(gYear, gMonth, 0)).getDate(); 
		}
		if(frm.employeeName.value.length<2)
		{
			alert("이름은 2글자 이상 입력해 주세요");
			frm.employeeName.select();
			return;
		} 
		if(frm.idNum1.value.length<6||frm.idNum1.value.length>6)
		{
			alert("주민등록 번호가 잘못되었습니다.");
			frm.idNum1.select();
			return;
		}
		if(frm.idNum2.value.length<7||frm.idNum2.value.length>7)
		{
			alert("주민등록 번호가 잘못되었습니다.");
			frm.idNum2.select();
			return;
		}
	 	if(idNumYear<0||idNum1Month<1||idNum1Month>12||idNum1Day<1){
			alert("주민등록 번호가 잘못되었습니다.");
			frm.idNum1.select();
			return;
		}
	 	if(idNum1Day>lastDayIdNum1){
	 		alert("주민등록 번호가 잘못되었습니다.");
			frm.idNum1.select();
			return;
	 	}
	 	
		if(idNum2Gender<1||idNum2Gender>5){
			alert("주민등록 번호가 잘못되었습니다.");
			frm.idNum2.select();
			return;
		} 
		var departmentCode=frm.departmentCode.value;
		if(departmentCode==""){
			alert("소속 부서를 선택해 주세요");
			frm.year1.select();
		}
		
	 	var skillCode = frm.skillCode;
	 	var graduationTypeCode=frm.graduationTypeCode;
	 	var fl1=false;
	 	var fl2=false;
	 	for(var i=0;i<skillCode.length;i++){
	 	   if(skillCode[i].checked == true){
	 	    fl1=true;
	 	   }
	 	}
 	    for(var i=0;i<graduationTypeCode.length;i++){
 	    	 if(graduationTypeCode[i].checked == true){
 		 	    fl2=true;
	 	   }
 	    }
	 	if(!fl2){
	 		alert("학력을 선택해 주세요");
	 		return;
	 	}
	 	if(!fl1){
	 		alert("기술을 하나이상 선택해 주세요");
	 		return;
	 	}
	 	if(idNumYear>gYear){
	 		alert("졸업일자나 주민등록번호가 잘못되었습니다.");
			frm.year1.select();
			return;
	 	}
	 	if(gDay>lastDayGdate||gDay==""||lastDayGdate==0){
			alert("졸업일자가 잘못되었습니다.");
			frm.year1.select();
			return;
		} 
	 	var baseSalary = frm.baseSalary.value.length;
	 	if(baseSalary<5){
	 		alert("기준급여가  잘못 되었습니다.");
	 		return;
	 	} */
	 	
		frm.action="EMP1010P11.do";
		frm.submit();
	}

	
	function numCheck(){
		
		if(!((event.keyCode>=48 && event.keyCode<=57)||
				(event.keyCode>=96 && event.keyCode<=105)||event.keyCode==8||event.keyCode==9)){
			event.returnValue=false;
			
			alert("숫자만 입력해 주세요");
		}
	}
		
</script>
</head>
<body>
<form name="frm01" method="post">
	<center>
		<table border="1">
			<tr>
				<td  align="center" colspan="6"> 사원 정보 등록 </td>
			</tr>
			<tr>
				<td align="center" >이  름</td>
				<td>
					<input name ="employeeName" value="${info.employeeName}" type="text" maxlength="10">
				</td>
				
				<td align="center" >주민번호</td>
				<td>
					<input name="idNum1" type="text" onkeydown="numCheck()" value="${idNumber1}" maxlength="6">-
					<input name="idNum2" type="password" onkeydown="numCheck()" value="${idNumber2}" maxlength="7">
				</td>
				<td align="center" > 소속부서 </td>
				<td>
					<select name="departmentCode">
						<option value=""></option>
							<c:forEach var="b"  items="${model}">
							<c:set var="fl" value="${false}"></c:set>
							<c:if test="${b.codeType=='DEPARTMENT'}">
							<c:forEach var="info"  items="${empInfo}">
								<c:if test="${b.codeDetail==info.departmentCode }">
									<option value="${b.codeDetail}" selected>${b.codeName }</option>
									<c:set var="fl" value="${true}"></c:set>
								</c:if>
							</c:forEach>
							<c:if test="${fl!=true}">
									<option value="${b.codeDetail}" >${b.codeName }</option>
							</c:if>
							</c:if>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td align="center" > 학  력 </td>
				<td>
					<c:forEach var="c"  items="${model}">
						<c:if test="${c.codeType=='GRADUATION'}">
						<c:set var="fl" value="${false}"></c:set>
						<c:forEach var="info"  items="${empInfo}">
							<c:if test="${c.codeDetail==info.graduationTypeCode}">
								<input type="radio" name="graduationTypeCode" value="${c.codeDetail}" checked> ${c.codeName }
								<c:set var="fl" value="${true}"></c:set>
							</c:if>
						</c:forEach>
						<c:if test="${fl!=true}">
							<input type="radio" name="graduationTypeCode" value="${c.codeDetail}" > ${c.codeName }
						</c:if>
						</c:if>
					</c:forEach>
				</td>
				<td align="center" > 기  술 </td>
				<td colspan="3">
					<c:forEach var="d"  items="${model}" >
						<c:if test="${d.codeType=='SKILL'}">
						<c:set var="fl" value="${false}"></c:set>
						<c:forEach var="s" items="${skills}">
						<c:if test="${d.codeDetail==s.skillCode}">
							<input type="checkbox" name="skillCode" value="${d.codeDetail}" checked>${d.codeName}
							<c:set var="fl" value="${true}"></c:set>
						</c:if>
						</c:forEach>
						<c:if test="${fl!=true}">
							<input type="checkbox" name="skillCode" value="${d.codeDetail}" >${d.codeName}
						</c:if>
						</c:if>
					</c:forEach>
				</td>
			</tr>
			<tr>
				<td align="center">졸업일</td>
				<td align="left" colspan="3">
					<select  name="year1">
						<option value=""> </option>
						<c:forEach var="y1" begin="1900" end="2014" step="1">
							<c:if test="${y1==year}">
							<option value="${y1}" selected>${y1} </option>
							</c:if>
							<option value="${y1}">${y1} </option>
						</c:forEach>
					</select> 년
					<select name="month1">
						<option value=""></option>
						<c:forEach var="m1" begin="1" end="12" step="1">
							<c:if test="${m1==month}">
							<option value="${m1}" selected>${m1} </option>
							</c:if>
							<option value="${m1}">${m1} </option>
						</c:forEach>
					</select> 월
					<select name="day1">
						<option value=""></option>
						<c:forEach var="d1" begin="1" end="31" step="1">
							<c:if test="${d1==day}"> 
							<option value="${d1}" selected>${d1} </option>
							</c:if>
							<option value="${d1}">${d1} </option>
						</c:forEach>
					</select> 일 
				</td>
				<td>기준급여</td>
				<td>
					<input name ="baseSalary" value="" type="text" onkeydown="numCheck()" maxlength="12">
				</td>
			</tr>
			<tr>
				<td align="center" colspan="6">
					<input type="button" name="insertInfo" onclick="insertFn()" value="등록"> &nbsp; 
					<input type="reset" value="초기화"> 
			</tr>
		</table>
		</center>
		${msg}
</form>

</body>
</html>